public class Inventory
extends java.lang.Object
| Modifier and Type | Field | Description |
|---|---|---|
private FoodItem[] |
inventory |
List of FoodItems that represents our inventory
|
private int |
numItems |
Number of items that a user has entered
|
| Constructor | Description |
|---|---|
Inventory() |
Default Constructor
|
| Modifier and Type | Method | Description |
|---|---|---|
boolean |
addItem(java.util.Scanner scanner) |
Reads from the Scanner object passed in and fills the data member fields of the class with valid data.
|
int |
alreadyExists(FoodItem item) |
Search for a food item and see if it is already stored in the inventory
|
java.lang.String |
toString() |
|
boolean |
updateQuantity(java.util.Scanner scanner,
boolean buyOrSell) |
Update the quanity stored in the food item
|
private FoodItem[] inventory
private int numItems
public boolean addItem(java.util.Scanner scanner)
scanner - - Scanner to use for inputtrue if all data members were successfully populated, false otherwisepublic int alreadyExists(FoodItem item)
item - - FoodItem to look forpublic boolean updateQuantity(java.util.Scanner scanner,
boolean buyOrSell)
scanner - - Input device to usebuyOrSell - - If we are to add to quantity (true) or remove (false)public java.lang.String toString()
toString in class java.lang.Object